<?php
/**
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file license.txt or that can be found at 
 * http://code.google.com/p/billboardce/wiki/License.
 *
 * @package    Oauth_Signature_Method_HMACSHA1
 * @category   Library
 * @license    http://code.google.com/p/billboardce/wiki/License New BSD License
 * @version    SVN: $Id: $
 */

/**
 * @package    Oauth_Signature_Method_HMACSHA1
 * @category   OAuth
 */
class Oauth_Signature_Method_HMACSHA1 extends Oauth_Signature_Method
{
	
    public function getName()
    {
		return "HMAC-SHA1";
	}
	
	public function buildSignature($request, $consumer, $token)
	{ 
		$baseString = $request->getSignatureBaseString();
		$request->baseString = $baseString;
		
		$keyParts = array ($consumer->secret, ($token) ? $token->secret : "" );
				
		$keyParts = Oauth_Util::urlencodeRfc3986($keyParts);
		$key = implode('&', $keyParts);
		
		return base64_encode(hash_hmac('sha1', $baseString, $key, true));
	}
}